/**
 * 客户档案操作控制类
 * ClientAction.java
 * Copyright (C) 2013 Gank
 * Simple Currency Trade System
 * 
 */
package com.gank.ct.pm.action;

import java.util.List;

import com.gank.ct.pm.domain.User;
import com.gank.ct.pm.service.IUserService;
import com.gank.ct.util.Toolkit;
import com.opensymphony.xwork2.ActionSupport;

/**
 * Copyright (C) 2013:Gank<br/>
 * Project:Curreny Trade<br/>
 * Module ID:<br/>
 * Comments:Simple Currency Trade System<br/>
 * JDK version used:JDK1.6<br/>
 * Package:com.gank.ct.action<br/>
 * Author:Michael Wu<br/>
 * Create Date:2013-11-3<br/>
 * Modified By:<br/>
 * Modified Date:<br/>
 * Why & What is modified:<br/>
 * Version:0.1<br/>
 */
@SuppressWarnings("serial")
public class LoginAction extends ActionSupport {
	// 客户档案业务处理接口
	private IUserService userService;
	private User user = new User();
	
	// 操作结束后跳转的地址
	private String finish_Url="main";



	public String login() {
		
		System.out.println("登陆 user["+user+"]");
		
		user.setUserpwd(Toolkit.encryptMD5(user.getUserpwd()));
		
		
		System.out.println("加密后登陆 user["+user+"]");
		
		List<User> lu = userService.findUser(user);
		
		System.out.println("lu ["+lu+"]");
		
		if (null != lu && lu.size() == 1){
			System.out.println(lu.size());
			return finish_Url;
		}
		else
			return "login";

	}

	public IUserService getUserService() {
		return userService;
	}

	public User getUser() {
		return user;
	}

	public void setUserService(IUserService userService) {
		this.userService = userService;
	}

	public void setUser(User user) {
		this.user = user;
	}

	
}
